package com.service.single.entity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Table;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;

/**
 * 系统用户
 *
 * @author admin
 */
@Table(appliesTo = "system_user", comment = "系统用户")
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SystemUser {

    @Id
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;
    @NotBlank(message = "用户名称必填")
    @ExcelProperty("用户名称")
    private String username;
    @NotBlank(message = "用户密码必填")
    private String password;

    @ExcelProperty("用户昵称")
    private String nickname;
    private String phone;
    /**
     * 1 男 2 女
     */
    private Integer gender;
    /**
     * 用户状态，正常、禁用
     */
    private Boolean status;
    /**
     * 最后一次登录时间
     */
    @TableField(value = "last_login")
    private LocalDateTime lastLogin;

    /**
     * 用户创建时间
     */
    @Column(columnDefinition = "datetime DEFAULT null COMMENT '创建时间'")
    @TableField(value = "created_time", fill = FieldFill.INSERT)
    private LocalDateTime createdTime;

    /**
     * 修改时间
     */
    @Column(columnDefinition = "datetime DEFAULT null COMMENT '修改时间'")
    @TableField(value = "update_time", fill = FieldFill.UPDATE)
    private LocalDateTime updateTime;
}
